package com.jml.service.order.impl.ss;


import com.jml.entity.OrderEntity;
import com.jml.mapper.OrderMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.Date;

@Service
public class ExectService {
    @Autowired
    private OrderMapper orderMapper;



    @Transactional
    public int updateOrder() {
        return orderMapper.updateOrder();
    }

    @Transactional
    public String insertOrder001(int age) throws InterruptedException {
        String orderId = System.currentTimeMillis() + "";
        OrderEntity newOrder = createOrder(orderId);
        // 1.向订单数据库表插入数据
        int result = orderMapper.addOrder(newOrder);
        Thread.sleep(10000);
        int j = 1 / age;
        return "1";
    }


     public OrderEntity createOrder(String orderId) {
        OrderEntity orderEntity = new OrderEntity();
        orderEntity.setName("111");
        orderEntity.setOrderCreatetime(new Date());
        // 价格是300元
        orderEntity.setOrderMoney(300d);
        // 状态为 未支付
        orderEntity.setOrderState(0);
        Long commodityId = 30L;
        // 商品id
        orderEntity.setCommodityId(commodityId);
        orderEntity.setOrderId(orderId);
        return orderEntity;
    }
}
